package ar.com.laley.centro.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import ar.com.laley.centro.common.Constantes;
import ar.com.laley.centro.forms.LoginForm;
import ar.com.laley.centro.servicios.ServicioLogin;

public class LoginAction extends GenericAction{

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception{
		
	    ActionForward forward = null;
		LoginForm loginForm = (LoginForm)form;
		if (ServicioLogin.isUsuarioRegistrado(loginForm.getId(),request)){
		    forward = mapping.findForward(Constantes.EXITO);
		}else{
			forward = mapping.findForward(Constantes.ERROR);
		}
		return forward;
	}
}
